package com.vates.reservas.web;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.vates.reservas.dominio.Hotel;
import com.vates.reservas.service.HotelService;

/**
 * Handles and retrieves the main requests
 */
@Controller
@RequestMapping(value = "/hotel/listado")
public class HotelListadoController {

	protected static Logger logger = Logger.getLogger("controller");

	@Autowired
	private HotelService hotelService;
	@RequestMapping(method = RequestMethod.GET)
	public ModelAndView handleRequest(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		List<Hotel> listado = hotelService.listadoHoteles();
		Map<String, Object> myModel = new HashMap<String, Object>();
		myModel.put("listado", listado);

		return new ModelAndView("hotel/listado", "model", myModel);
	}
}